<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:t="http://myfaces.apache.org/tomahawk"
	xmlns:util="http://java.sun.com/jsf/composite/util">

<ui:composition>
	<h:form>
		<h:panelGrid styleClass="vertical-menu-cell"
			columnClasses="optionList" columns="1" cellspacing="0"
			cellpadding="0">
			<rich:dropDownMenu
				style="border:1px solid #{a4jSkin.panelBorderColor}" label="Akcje"
				mode="server" jointPoint="topRight" direction="bottomRight">
				<rich:menuItem label="Oznacz jako wykonane"
					action="#{transactionsBean.markAsDone}">
				</rich:menuItem>
				<rich:menuItem label="Usuń"
					action="#{transactionsBean.removeTransaction}" />
			</rich:dropDownMenu>
			<h:commandButton value="Odśwież"
				actionListener="#{adminPanelBean.refreshTransactionList}" />
		</h:panelGrid>
		<rich:extendedDataTable value="#{adminPanelBean.transaction_list}"
			var="transaction" id="transaction_table"
			style="height:100%; width:100%;" selectionMode="single"
			selection="#{adminPanelBean.selection}">
			<a4j:ajax execute="@form" event="selectionchange"
				listener="#{adminPanelBean.selectionTransactionListener}"
				render="@all" />
			<f:facet name="header">
				<h:outputText value="Tabela transakcji" />
			</f:facet>
			<rich:column>
				<f:facet name="header">
					<h:outputText value="Imie" />
				</f:facet>
				<h:outputText value="#{transaction.login.client.first_name}" />
			</rich:column>
			<rich:column>
				<f:facet name="header">
					<h:outputText value="Nazwisko" />
				</f:facet>
				<h:outputText value="#{transaction.login.client.last_name}" />
			</rich:column>
			<rich:column>
				<f:facet name="header">
					<h:outputText value="Data" />
				</f:facet>
				<h:outputText value="#{transaction.login.login_date}" />
			</rich:column>
		</rich:extendedDataTable>
	</h:form>

	<h:form>
		<rich:panel>
			<h:panelGrid columns="1">
				<h:panelGrid columns="2" cellpadding="4">
					<util:formField
						beanProperty="#{transactionsBean.transaction.login.client.first_name}"
						title="Imię" size="48" required="true" />
					<util:formField
						beanProperty="#{transactionsBean.transaction.login.client.last_name}"
						title="Nazwisko" size="49" required="true" />
				</h:panelGrid>
				<h:outputText value="Adres:" style="font-size: 14px;" />
				<h:panelGrid columns="3" cellpadding="4">
					<util:formField
						beanProperty="#{transactionsBean.transaction.login.client.street}"
						title="Ulica" size="50" required="true" />
					<util:formField
						beanProperty="#{transactionsBean.transaction.login.client.house_number}"
						title="Nr domu" size="20" required="true" />
					<util:formField
						beanProperty="#{transactionsBean.transaction.login.client.apartment_number}"
						title="Nr mieszkania" size="20" required="true" />
				</h:panelGrid>
				<h:panelGrid columns="2" cellpadding="4">
					<util:formField
						beanProperty="#{transactionsBean.transaction.login.client.post}"
						title="Poczta" size="70" required="true" />
					<util:formField
						beanProperty="#{transactionsBean.transaction.login.client.postal_code}"
						title="Kod pocztowy" size="27" required="true" />
				</h:panelGrid>
				<br />

				<h:outputText value="Kontakt:" style="font-size: 14px;" />
				<util:formField
					beanProperty="#{transactionsBean.transaction.login.client.email}"
					title="E-mail" size="106" required="true" />
				<util:formField
					beanProperty="#{transactionsBean.transaction.login.client.phone}"
					title="Telefon" size="106" required="true" />
			</h:panelGrid>
		</rich:panel>

		<rich:dataTable id="confirmOrdersBookTabel" style="width:100%;"
			iterationStatusVar="it" value="#{transactionsBean.transactionBooks}" var="var">
			<rich:column>
				#{it.index}
			</rich:column>

			<rich:column>
				<f:facet name="header">
				Tytuł
            </f:facet>
				<h:outputText value="#{var.book.title}" styleClass="bookTitleCart" />
			</rich:column>

			<rich:column>
				<f:facet name="header">
				Cena
            </f:facet>
				<h:outputText value="#{var.book.price}" styleClass="bookPriceCart">
					<f:convertNumber type="currency" pattern="  #0.00 zł" />
				</h:outputText>
			</rich:column>

			<rich:column>
				<f:facet name="header">
				Liczba sztuk
            </f:facet>
				<h:outputText value="#{var.bought_books}" size="1" />
			</rich:column>


			<f:facet name="footer">
                Suma: <h:outputText value="#{transactionsBean.price}">
					<f:convertNumber type="currency" pattern="  #0.00 zł" />
				</h:outputText>
			</f:facet>
		</rich:dataTable>

	</h:form>

</ui:composition>
</html>
